using IcsSEMCtrl.Db;
using IcsSEMCtrl.Device;
using IcsSEMCtrl.Global.Device;
using IcsSEMCtrl.Service.Logger;
using System;
using System.Collections.Generic;
namespace IcsSEMCtrl.Service.Device
{
	public class DeviceManager : Manager
	{
		private const string CLASS = "DeviceManager";
		protected Dictionary<string, Equipment> devices = new Dictionary<string, Equipment>();
		public DeviceManager(string ownerId, string id) : base(ownerId, id)
		{
			this.loadDevices();
		}
		public void loadDevices()
		{
			this.devices = Equipment.LoadEquipments();
		}
		public Equipment GetDevice()
		{
			Equipment result;
			if (this.devices.Count == 1)
			{
				using (Dictionary<string, Equipment>.KeyCollection.Enumerator enumerator = this.devices.Keys.GetEnumerator())
				{
					if (enumerator.MoveNext())
					{
						string current = enumerator.Current;
						result = this.devices[current];
						return result;
					}
				}
			}
			result = null;
			return result;
		}
		public Equipment GetLifter()
		{
			Equipment equipment = null;
			foreach (string current in this.devices.Keys)
			{
				equipment = this.devices[current];
				if (equipment.EquipmentType.Equals(EquipmentType.LIFTER))
				{
					break;
				}
			}
			return equipment;
		}
		protected override int Add(DBConnection theDB)
		{
			return base.Add(theDB);
		}
		protected override void Delete(DBConnection theDB)
		{
			base.Delete(theDB);
		}
		protected override void Load(DBConnection theDB)
		{
			base.Load(theDB);
		}
		protected override int Save(DBConnection theDB)
		{
			int result = base.Save(theDB);
			return result;
		}
	}
}
